import React from 'react';
import { Tooltip } from '@arco-design/web-react';
import { User } from '@/api/interface/authentication';
import Delete from '@/assets/delete.svg';

export function getColumns(
  t: unknown,
  callback: (record: User) => Promise<void>,
  action: boolean
) {
  const columns = [
    {
      title: '#',
      dataIndex: 'id',
    },
    {
      title: t['auth.columns.username'],
      dataIndex: 'name',
    },
    {
      title: t['auth.columns.action'],
      dataIndex: 'action',
      render: (_, record: User) => (
        <Tooltip position="bottom" content={t['auth.operations.delete']}>
          <Delete
            style={{
              width: 20,
              cursor: 'pointer',
              fill: 'var(--color-text-2)',
            }}
            onClick={() => callback(record)}
          />
        </Tooltip>
      ),
    },
  ];
  return action
    ? columns
    : columns.filter((item) => item.dataIndex !== 'action');
}
